rcar_gen3: drivers: scif: Use TEND flag for transmission end detection
authorMarek Vasut <[email protected]>
Thu, 27 Dec 2018 19:31:22 +0000 (20:31 +0100)
committerMarek Vasut <[email protected]>
Tue, 8 Jan 2019 13:08:44 +0000 (14:08 +0100)
Use the SCIF SCFSR:TEND bit to check that all data were transmitted by
the SCIF and that there are no more valid data to transmit in the FIFO.

Signed-off-by: Marek Vasut <[email protected]>
drivers/renesas/rcar/scif/scif.S

index 1cc0d5909137eeb67a009bed9fd543318c2f5222..09dc90b8d100ff06f3ee44131adc4908079c57fc 100644 (file)
@@ -75,6 +75,8 @@
 #if SCIF_CLK == SCIF_EXTARNAL_CLK
 #define        SCSCR_CKE_INT_CLK       (SCSCR_CKE_BRG)
 #else
+#define        SCFSR_TEND_MASK         (1 << 6)
+#define        SCFSR_TEND_TRANS_END    (0x0040)
 #define        SCSCR_CKE_INT_CLK       (SCSCR_CKE_INT)
 #endif
 #define        SCFSR_INIT_DATA         (0x0000)
@@ -281,6 +283,11 @@ func console_core_putc
        bcs     2b
        strb    w0, [x1, #SCIF_SCFTDR]
 
+       /* Clear TEND flag */
+       ldrh    w2, [x1, #SCIF_SCFSR]
+       and     w2, w2, #~SCFSR_TEND_MASK
+       strh    w2, [x1, #SCIF_SCFSR]
+
        ret
 endfunc console_core_putc
 
@@ -309,16 +316,12 @@ endfunc console_getc
 func console_flush
        ldr     x0, =SCIF2_BASE
 1:
-       ldrh    w1, [x0, #SCIF_SCFDR]
-       ubfx    w1, w1, #8, #5
-       cmp     w1, #0
+       /* Check TEND flag */
+       ldrh    w1, [x0, #SCIF_SCFSR]
+       and     w1, w1, #SCFSR_TEND_MASK
+       cmp     w1, #SCFSR_TEND_TRANS_END
        bne     1b
 
-       mov x0, #100
-       mov x3, x30
-       bl rcar_micro_delay
-       mov x30, x3
-
        ldr     x0, =SCIF2_BASE
        ldrh    w1, [x0, #SCIF_SCSCR]
        and     w1, w1, #~(SCSCR_TE_EN + SCSCR_RE_EN)